package com.dc.juc.example._5_immutable;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import lombok.extern.slf4j.Slf4j;

/**
 * Description: Guava 不可变工具类
 *
 *  ImmutableList
 *  ImmutableSet
 *  ImmutableMap
 *  ImmutableSortedMap
 *  ImmutableCollection
 *  ImmutableEnumSet
 *  ...
 *
 * @author: gdc
 * @date: 2021/8/4
 * @version 1.0
 */
@Slf4j
public class Immutable3 {

    private final static ImmutableList list = ImmutableList.of(1, 2, 3, 4, 5);

    private final static ImmutableSet set = ImmutableSet.copyOf(list);

    private final static ImmutableMap<Integer, Integer> map = ImmutableMap.of(1, 2, 3, 4, 5, 6);

    private final static ImmutableMap<Integer, Integer> map2 = ImmutableMap.<Integer, Integer>builder().put(7, 8).put(9, 10).put(11, 12).build();

    public static void main(String[] args){
        log.info("list 1: {}", list);
        log.info("set 2: {}", set);
        log.info("map 3: {}", map);
        log.info("map 4: {}", map2);

        list.add(1);
        log.info("{}", list);

        set.add(2);
        map.put(1, 10);
        map2.put(111, 222);
    }
}
